package com.example.kotlin

class Person3(val name: String = "Unknown", val age: Int = 0) {
    init {
        println("Initialized with name: $name and age: $age")
    }

    // 打印方法
    fun printInfo() {
        println("Person(name=$name, age=$age)")
        println("-----------------")
    }
}

fun main() {
    // 直接使用默认参数，不需要定义额外的次级构造函数
    val person1 = Person3("Alice", 30)
    person1.printInfo()  // 输出：Person(name=Alice, age=30)

    val person2 = Person3("Bob")
    person2.printInfo()  // 输出：Person(name=Bob, age=0)

    val person3 = Person3()
    person3.printInfo()  // 输出：Person(name=Unknown, age=0)

    val person4 = Person3("123", 40)
    person4.printInfo()
}
